package edu.sctu.servlet;


import edu.sctu.User;
import edu.sctu.dao.UserDao;
import edu.sctu.util.DbUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;

/**
 * 用户编辑Servlet
 */
public class UserEditServlet extends HttpServlet {

    DbUtil dbUtil = new DbUtil();
    UserDao userDao = new UserDao();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");


        //用户列表某一用户的参数

        //当前用户


        int userId = Integer.parseInt(request.getParameter("id"));
        String userName = request.getParameter("username");
        String password = request.getParameter("password");

        Connection connection = null;
        try {
            connection=dbUtil.getCon();
            User user = new User(userId,userName,password);//用户表单数据


        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                //数据库关闭
                dbUtil.closeCon(connection);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


    }
}
